/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * aboutMeEditPanel.java
 *
 * Created on Dec 3, 2012, 4:05:29 PM
 */
package cs341.cs.uwosh.edu.jBeats;

/**
 *
 * @author haibut41
 */
public class aboutMeEditPanel extends javax.swing.JPanel {
    User currentUser = null;
    String username = "";

    /** Creates new form aboutMeEditPanel */
    public aboutMeEditPanel() {
        initComponents();
    }
    
    public aboutMeEditPanel(User user){
        initComponents();
        username = user.getUserName();
        favoriteBandField.setText(user.getFavoriteBand());
        favoriteSongField.setText(user.getFavoriteSong());
        favoriteGenreField.setText(user.getFavoriteGenre());
        ageField.setText(""+user.getAge());
        genderField.setText(user.getGender());
        locationField.setText(user.getLocation());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        aboutMeEditPanel = new javax.swing.JPanel();
        aboutMeLabelEdit = new javax.swing.JLabel();
        staticBandLabelEdit = new javax.swing.JLabel();
        staticGenreLabelEdit = new javax.swing.JLabel();
        staticSongLabelEdit = new javax.swing.JLabel();
        staticLocationLabelEdit = new javax.swing.JLabel();
        staticGenderLabelEdit = new javax.swing.JLabel();
        staticAgeLabelEdit = new javax.swing.JLabel();
        ageField = new javax.swing.JTextField();
        genderField = new javax.swing.JTextField();
        locationField = new javax.swing.JTextField();
        favoriteGenreField = new javax.swing.JTextField();
        favoriteSongField = new javax.swing.JTextField();
        favoriteBandField = new javax.swing.JTextField();
        saveButton = new javax.swing.JButton();

        aboutMeEditPanel.setBackground(new java.awt.Color(84, 116, 191));
        aboutMeEditPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255, 102, 0), null));
        aboutMeEditPanel.setName("aboutMeEditPanel"); // NOI18N
        aboutMeEditPanel.setPreferredSize(new java.awt.Dimension(326, 75));

        aboutMeLabelEdit.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
        aboutMeLabelEdit.setText("About Me:");
        aboutMeLabelEdit.setName("aboutMeLabelEdit"); // NOI18N

        staticBandLabelEdit.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        staticBandLabelEdit.setText("Favorite Band:");
        staticBandLabelEdit.setName("staticBandLabelEdit"); // NOI18N

        staticGenreLabelEdit.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        staticGenreLabelEdit.setText("Favorite Genre:");
        staticGenreLabelEdit.setName("staticGenreLabelEdit"); // NOI18N

        staticSongLabelEdit.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        staticSongLabelEdit.setText("Favorite Song:");
        staticSongLabelEdit.setName("staticSongLabelEdit"); // NOI18N

        staticLocationLabelEdit.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        staticLocationLabelEdit.setText("Location:");
        staticLocationLabelEdit.setName("staticLocationLabelEdit"); // NOI18N

        staticGenderLabelEdit.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        staticGenderLabelEdit.setText("Gender:");
        staticGenderLabelEdit.setName("staticGenderLabelEdit"); // NOI18N

        staticAgeLabelEdit.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        staticAgeLabelEdit.setText("Age:");
        staticAgeLabelEdit.setName("staticAgeLabelEdit"); // NOI18N

        ageField.setText("4096");
        ageField.setName("ageField"); // NOI18N

        genderField.setText("Male");
        genderField.setName("genderField"); // NOI18N

        locationField.setText("Wisconsin");
        locationField.setName("locationField"); // NOI18N

        favoriteGenreField.setText("Pop");
        favoriteGenreField.setName("favoriteGenreField"); // NOI18N

        favoriteSongField.setText("Hit Me Baby One More Time");
        favoriteSongField.setName("favoriteSongField"); // NOI18N

        favoriteBandField.setText("Britney Spears");
        favoriteBandField.setName("favoriteBandField"); // NOI18N

        saveButton.setText("Save Changes");
        saveButton.setName("saveButton"); // NOI18N
        saveButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                saveButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout aboutMeEditPanelLayout = new javax.swing.GroupLayout(aboutMeEditPanel);
        aboutMeEditPanel.setLayout(aboutMeEditPanelLayout);
        aboutMeEditPanelLayout.setHorizontalGroup(
            aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(aboutMeEditPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(aboutMeLabelEdit)
                    .addGroup(aboutMeEditPanelLayout.createSequentialGroup()
                        .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(staticAgeLabelEdit)
                            .addComponent(staticGenderLabelEdit)
                            .addComponent(staticLocationLabelEdit)
                            .addComponent(staticGenreLabelEdit)
                            .addComponent(staticSongLabelEdit)
                            .addComponent(staticBandLabelEdit))
                        .addGap(3, 3, 3)
                        .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(favoriteBandField, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(favoriteGenreField, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(locationField, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(genderField, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(ageField, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(favoriteSongField, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)))
                    .addComponent(saveButton))
                .addContainerGap())
        );
        aboutMeEditPanelLayout.setVerticalGroup(
            aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(aboutMeEditPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(aboutMeLabelEdit)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(staticAgeLabelEdit)
                    .addComponent(ageField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(staticGenderLabelEdit)
                    .addComponent(genderField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(staticLocationLabelEdit)
                    .addComponent(locationField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(staticGenreLabelEdit)
                    .addComponent(favoriteGenreField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(staticSongLabelEdit)
                    .addComponent(favoriteSongField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(aboutMeEditPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(staticBandLabelEdit)
                    .addComponent(favoriteBandField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(saveButton))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(aboutMeEditPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(aboutMeEditPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

private void saveButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveButtonMouseClicked
    DatabaseInfo.updateUserBand(username, favoriteBandField.getText());
    DatabaseInfo.updateUserFavSong(username, favoriteSongField.getText());
    DatabaseInfo.updateUserGenre(username, favoriteGenreField.getText());
    DatabaseInfo.updateUserGender(username, genderField.getText());
    DatabaseInfo.updateUserLocation(username, locationField.getText());
    DatabaseInfo.updateUserAge(username, Integer.parseInt(ageField.getText()));
    
}//GEN-LAST:event_saveButtonMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel aboutMeEditPanel;
    private javax.swing.JLabel aboutMeLabelEdit;
    private javax.swing.JTextField ageField;
    private javax.swing.JTextField favoriteBandField;
    private javax.swing.JTextField favoriteGenreField;
    private javax.swing.JTextField favoriteSongField;
    private javax.swing.JTextField genderField;
    private javax.swing.JTextField locationField;
    private javax.swing.JButton saveButton;
    private javax.swing.JLabel staticAgeLabelEdit;
    private javax.swing.JLabel staticBandLabelEdit;
    private javax.swing.JLabel staticGenderLabelEdit;
    private javax.swing.JLabel staticGenreLabelEdit;
    private javax.swing.JLabel staticLocationLabelEdit;
    private javax.swing.JLabel staticSongLabelEdit;
    // End of variables declaration//GEN-END:variables
}
